const DataTypes = require("sequelize").DataTypes;
/**
 * 文章业务模型
 */
const _Article = require('./Article')
const _ContentCategory = require('./Category')
const _ContentTags = require('./Tags')
const _ContentArticleTags = require('./ArticleTags')



function contentInitModels(sequelize) {
  const Article = _Article(sequelize, DataTypes);
  const ContentCategory = _ContentCategory(sequelize, DataTypes);
  const ContentTags = _ContentTags(sequelize, DataTypes);
  const ContentArticleTags = _ContentArticleTags(sequelize, DataTypes);

  Article.belongsToMany(ContentTags, {
    through: ContentArticleTags,
    foreignKey: 'articleId',
    otherKey: 'tagsId',
  })
  ContentTags.belongsToMany(Article, {
    through: ContentArticleTags,
    foreignKey: 'tagsId',
    otherKey: 'articleId',
  })

  return {
    Article,
    ContentCategory,
    ContentTags,
    ContentArticleTags
  };
}
module.exports = contentInitModels;
module.exports.ContentInitModels = contentInitModels;
module.exports.default = contentInitModels;
